package com.ruoyi.app.controller.shop.mapper;

import com.ruoyi.common.core.dao.BaseMapper;
import com.ruoyi.common.entity.DO.shop.ShopDO;
import com.ruoyi.common.entity.VO.shop.ShopVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface IShopMapper extends BaseMapper<ShopDO> {

    @Select("SELECT shop_name shopName,shop_logo shopLogo,shop_address shopAddress,shop_tel shopTel FROM shop WHERE id=#{id} and review_status=1 and is_delete=0 and is_enable=1")
    ShopVO getShopGeneralInfo(Long id);

    @Select("SELECT shop_name shopName,shop_logo shopLogo,shop_address shopAddress,shop_tel shopTel," +
            "ACOS(COS(RADIANS(shop_address_lat)) * COS(RADIANS(#{latitude})) * COS(RADIANS(shop_address_lon) - RADIANS(#{longitude})) + SIN(RADIANS(shop_address_lat)) * SIN(RADIANS(#{latitude}))) * 6378 as distance" +
            " FROM shop WHERE id=#{id} and review_status=1 and is_delete=0 and is_enable=1")
    ShopVO getShopGeneralInfoWithDistance(@Param("id") Long id,@Param("latitude") double latitude, @Param("longitude") double longitude);
}
